package servlet1;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//@WebServlet("/servlet1")  // 启用注解
public class Servlet1 extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        // 设置请求属性
        request.setAttribute("message", "Hello from Servlet1!");

        // 使用请求转发到Servlet2（保持同一个请求）
        request.getRequestDispatcher("/servlet2").forward(request, response);
    }
}